//
//  WQNewFutureController.m
//  sanwuWeiboOC
//
//  Created by 王先强 on 15/12/11.
//  Copyright © 2015年 王先强. All rights reserved.
//

#import "WQNewFutureController.h"
#import "WQNewFutureViewCell.h"
@interface WQNewFutureController ()

@end

@implementation WQNewFutureController

static NSString * const WQNewFutureViewCellID = @"WQNewFutureViewCellID";

- (void)viewDidLoad {
    [super viewDidLoad];
    

    [self.collectionView registerClass:[WQNewFutureViewCell class] forCellWithReuseIdentifier:WQNewFutureViewCellID];
    
}

-(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 4;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    WQNewFutureViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:WQNewFutureViewCellID forIndexPath:indexPath];
    cell.backgroundColor = WQRandomColor;
    cell.cellIndex = indexPath.item + 1;
    return cell;
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSInteger currentPage = scrollView.contentOffset.x / self.view.width;
    
    WQLog(@"%d",currentPage);
    if (currentPage == 3) {
        WQNewFutureViewCell *cell = [self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:currentPage inSection:0]];
        [cell startAnimation];
    }
}




-(instancetype)init{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    if (self = [super initWithCollectionViewLayout:layout]) {
        layout.itemSize = self.view.bounds.size;
        layout.minimumInteritemSpacing = 0;
        layout.minimumLineSpacing = 0;
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        self.collectionView.showsHorizontalScrollIndicator = NO;
        self.collectionView.bounces = NO;
        self.collectionView.pagingEnabled = YES;
        
    }
    return self;
}


@end
